home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6452 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Cast from function expecting a reference to one expecting a pointer
  5. Date: 8 Feb 1996 14:36:24 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4fd1p8$hf3@dawn.mmm.com>
  8. References: <310DF504.69E6@tees.ac.uk> <4f8dui$kik@druid.borland.com>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Pete Becker (pete@borland.com) wrote:
  13. > In article <310DF504.69E6@tees.ac.uk>, H.Lawson@tees.ac.uk says...
  14. > >
  15. > >Is it legal to cast from a function which expects a reference to one 
  16. > >expecting a pointer, as in the sample code below.
  17. > >
  18.  
  19. > No.
  20.  
  21. It is legal to cast a pointer to a function into a pointer to a different
  22. type of function.  Casting back to the original type is guaranteed to
  23. bring the original pointer back.
  24.  
  25. But calling a function of one type through a pointer to a function of a
  26. different type results in undefined behavior.
  27. --
  28. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  29. 3M Company                      phone:  (612) 737-4643
  30. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  31. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  32.     But 3M speaks for me -- I did not write the following line:
  33.  
  34. Opinions expressed herein are my own and may not represent those of 3M.
  35.